#include<iostream>
#include<vector>
#include<string>
using namespace std;
int main()
{
	int x = 0;
	int y = 0;
	cin >> x >> y;
	vector<vector<string>> flag;
	vector<vector<char>> num('0');
	x += 2;
	y += 2;

	for (int i = 1; i < y - 1; i++)
	{
		for (int j = 1; j < x - 1; j++)
		{
			cin >> flag[i][j];
			if (flag[i][j] == "*")
			{
				num[i - 1][j - 1] += 1;
				num[i - 1][j] += 1;
				num[i - 1][j + 1] += 1;
				num[i][j - 1] += 1;
				num[i][j + 1] += 1;
				num[i + 1][j - 1] += 1;
				num[i + 1][j] += 1;
				num[i + 1][j + 1] += 1;
			}
		}
	}

	return 0;
}